﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D.Domain.SystemDomain.SysUserDomain.ValueObjects
{
    public class Email
    {
        public string Value { get; }

        public Email(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("Email cannot be empty");
            }

            if (!IsValidEmail(value))
            {
                throw new ArgumentException("Invalid email format");
            }

            Value = value;
        }

        private static bool IsValidEmail(string value)
        {
            // 验证邮箱格式
            return true;
        }

        public override string ToString()
        {
            return Value;
        }

        public static implicit operator string(Email email)
        {
            return email.Value;
        }

        public static explicit operator Email(string value)
        {
            return new Email(value);
        }
    }
}

